package com.hackordie.operations.queries;

import com.hackordie.commons.HackOrDieResult;
import com.hackordie.commons.authorities.User;
import com.hackordie.exceptions.HackOrDieException;
import com.hackordie.operations.AHackOrDieOperationAuth;

public class QueryLoginUser extends AHackOrDieOperationAuth {

	private final String username;
	private final String password;

	public QueryLoginUser(String username, String password) {
		super();
		this.username = username;
		this.password = password;
	}

	@Override
	protected boolean checkParameters() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	protected HackOrDieResult executeOperation() throws HackOrDieException {
		final User user = userDao.get(username);
		if (user != null) {
			if (user.getUserPassword().equals(password)) {
				result.setObject(user);
			}
		}
		return result;
	}

}
